import service from './index';
import {
  UserLogin,
  IModifyPwd,
  LoginToken,
  IQrCodeParams,
  IQrCodeLoginParams,
} from '../type';
import { baseURL } from './index';
import { course } from './course';
import { student } from './student';
import { teacher } from './teacher';
import { coSelection } from './coSelection';
import { coManage } from "./coManage";
import { scManage } from "./scManage";
import { score } from "./score";
import { file } from "./file";
import { bindWeixin } from './bindWeixin';

export const useAPI = () => {
  return {
    course,
    student,
    teacher,
    coSelection,
    coManage,
    scManage,
    score,
    file,
    bindWeixin,
    baseUrl: baseURL,
    //登录
    login: (data: UserLogin) => {
      return service({
        url: '/login',
        method: 'post',
        data,
      });
    },
    //token换个人信息
    getInfoByToken: (data: LoginToken) => {
      return service({
        url: '/getInfoByToken',
        method: 'post',
        data,
      });
    },
    getQrCode: (qrCodeParam: IQrCodeParams) => {
      return service({
        url: `/getQrCode`,
        method: 'get',
        params: qrCodeParam
      });
    },
    loginByQrCode: (timeStamp: IQrCodeLoginParams) => {
      return service({
        url: `/loginByQrCode`,
        method: 'get',
        params: timeStamp
      });
    },
    //修改密码
    modifyPwd: (data: IModifyPwd, role: string) => {
      return service({
        url: `/${role}/modifyPwd`,
        method: 'post',
        data,
      });
    },
    //根据工号，学号查询信息
    getUserInfo: (params: any, role: string) => {
      return service({
        url: `/${role}/getInfo`,
        method: 'get',
        params,
      });
    },

  }
};
